<!DOCTYPE html>
<html lang="en">

	<head>
		<meta charset="utf-8">
		<title>FH Admin</title>
		<!-- HTML5 Shim and Respond.js IE10 support of HTML5 elements and media queries -->
		<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
		<!--[if lt IE 10]>
  <script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
  <script src="https://oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js"></script>
  <![endif]-->
		<!-- Meta -->
		<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=0, minimal-ui">
		<meta http-equiv="X-UA-Compatible" content="IE=edge" />
		<meta name="author" content="FH Admin QQ313596790" />

		<link rel="icon" href="../../../assets/images/favicon.ico" type="image/x-icon">
		<link rel="stylesheet" href="../../../assets/fonts/material/css/materialdesignicons.min.css">
		<link rel="stylesheet" href="../../../assets/fonts/fontawesome/css/fontawesome-all.min.css">
		<link rel="stylesheet" href="../../../assets/plugins/animation/css/animate.min.css">
		<link rel="stylesheet" href="../../../assets/css/style.css">

		<!-- vue -->
		<script src="../../../assets/js-vue/vue.js"></script>
		<!--全局配置-->
		<script src="../../../assets/js-v/config.js"></script>

	</head>

	<body>

		<!-- [加载状态 ] start -->
		<div class="loader-bg">
			<div class="loader-track">
				<div class="loader-fill"></div>
			</div>
		</div>
		<!-- [ 加载状态  ] End -->

		<!-- [ 主内容区 ] start -->
		<div class="pcoded-wrapper" id="app">
			<div class="pcoded-content">
				<div class="pcoded-inner-content">
					<div class="main-body">
						<div class="page-wrapper">
							<!-- [ Main Content ] start -->
							<div class="row">

								<!-- [ Hover-table ] start -->
								<div class="col-xl-12">
									<div class="card">

										<!-- 检索  -->
										<div style="padding-left: 20px;padding-top: 15px;">
											<table style="margin-top:5px;">
												<tr>
													<td>
														<div class="input-group input-group-sm mb-3">
															<input class="form-control" type="text" v-model="KEYWORDS" placeholder="这里输入关键词" />
														</div>
													</td>
													<td style="vertical-align:top;padding-left:5px;">
														<a class="btn btn-light btn-sm" v-on:click="getList" style="width: 23px;height:30px;margin-top:1px;" title="检索"><i style="margin-top:-3px;margin-left: -6px;" class="feather icon-search"></i></a>
														<a v-show="toExcel" class="btn btn-light btn-sm" v-on:click="goExcel" style="width: 23px;height:30px;margin-top:1px;margin-left: -9px;" title="导出到excel表格">
															<i style="margin-top:-3px;margin-left: -6px;" class="mdi mdi-cloud-download"></i>
														</a>
													</td>
													<td v-show="loading">
														<!-- [加载状态 ] start -->
														<div class="d-flex justify-content-center" style="margin-top:-10px;">
															<div class="spinner-grow spinner-grow-sm" role="status">
																<span class="sr-only">Loading...</span>
															</div>
														</div>
														<!-- [ 加载状态  ] End -->
													</td>
												</tr>
											</table>
										</div>
										<!-- 检索  -->
										<div class="card-block table-border-style" style="margin-top: -15px">
											<div class="table-responsive">
												<table class="table table-hover">
													<thead>
														<tr>
															<th style="width: 50px;" id="cts">
																<div class="checkbox d-inline">
																	<input type="checkbox" name="fhcheckbox" id="zcheckbox">
																	<label style="max-height: 12px;" for="zcheckbox" class="cr"></label>
																</div>
															</th>
															<th style="width:50px;">NO</th>
															<th>文件名</th>
															<th>版本号</th>
															<th>平台(1.安卓 2.苹果)</th>
															<th>操作</th>
														</tr>
													</thead>

													<tbody>
														<!-- 开始循环 -->
														<template v-for="(data,index) in varList">
															<tr>
																<td>
																	<div class="checkbox d-inline">
																		<input type="checkbox" v-bind:id="'zcheckbox'+index" name='ids' v-bind:value="data.APKVERSION_ID">
																		<label style="max-height: 12px;" v-bind:for="'zcheckbox'+index" class="cr"></label>
																	</div>
																</td>
																<td scope="row">{{page.showCount*(page.currentPage-1)+index+1}}</td>
																<td>{{data.FILENAME}}</td>
																<td>{{data.VERSION}}</td>
																<td>{{data.PLAT}}</td>
																<td>
																	<a v-show="edit" title="修改" v-on:click="goEdit(data.APKVERSION_ID)" style="cursor:pointer;"><i class="feather icon-edit-2"></i></a>
																	<a v-show="del" title="删除" v-on:click="goDel(data.APKVERSION_ID)" style="cursor:pointer;"><i class="feather icon-x"></i></a>
																</td>
															</tr>
														</template>
														<tr v-show="varList.length==0">
															<td colspan="10">没有相关数据</td>
														</tr>
													</tbody>
												</table>
												<table style="width:100%;margin-top:15px;">
													<tr>
														<td style="vertical-align:top;">
															<a v-show="add" class="btn btn-light btn-sm" v-on:click="goAdd">新增</a>
															<a v-show="del" class="btn btn-light btn-sm" v-on:click="makeAll('确定要删除选中的数据吗?')">删除</a>
														</td>
														<td style="vertical-align:top;">
															<div style="float: right;padding-top: 0px;margin-top: 0px;" v-html="page.pageStr"></div>
														</td>
													</tr>
												</table>
											</div>
										</div>

									</div>
								</div>
								<!-- [ Hover-table ] end -->

							</div>
							<!-- [ Main Content ] end -->
						</div>
					</div>
				</div>
			</div>
		</div>
		<!-- [ 主内容区 ] end -->

		<script type="text/javascript" src="../../../assets/js/jquery-1.7.2.js"></script>
		<script type="text/javascript" src="../../../assets/js/pre-loader.js"></script>
		<script src="../../../assets/plugins/sweetalert/js/sweetalert.min.js"></script>
		<!-- 表单验证提示 -->
		<script src="../../../assets/js/jquery.tips.js"></script>

		<script type="text/javascript">
			var vm = new Vue({
				el: '#app',

				data: {
					varList: [], //list
					page: [], //分页类
					KEYWORDS: '', //检索条件,关键词
					showCount: -1, //每页显示条数(这个是系统设置里面配置的，初始为-1即可，固定此写法)
					currentPage: 1, //当前页码
					add: false, //增
					del: false, //删
					edit: false, //改
					toExcel: false, //导出到excel权限
					loading: false //加载状态
				},

				methods: {
					
					//初始执行
					init() {
						//复选框控制全选,全不选
						$('#zcheckbox').click(function() {
							if($(this).is(':checked')) {
								$("input[name='ids']").click();
							} else {
								$("input[name='ids']").attr("checked", false);
							}
						});
						this.getList();
					},

					//获取列表
					getList: function() {
						this.loading = true;
						$.ajax({
							xhrFields: {
								withCredentials: true
							},
							type: "POST",
							url: httpurl + 'api/apkversion/list?showCount=' + this.showCount + '&currentPage=' + this.currentPage,
							data: { KEYWORDS: this.KEYWORDS, tm: new Date().getTime() },
							dataType: "json",
							success: function(data) {
								if("success" == data.data.result) {
									vm.varList = data.data.varList;
									vm.page = data.data.page;
									vm.hasButton();
									vm.loading = false;
									$("input[name='ids']").attr("checked", false);
								} else if("exception" == data.data.result) {
									showException("APK版本管理", data.data.exception); //显示异常
								}
							}
						}).done().fail(function() {
							swal("登录失效!", "请求服务器无响应，稍后再试", "warning");
							setTimeout(function() {
								window.location.href = "../../login.html";
							}, 2000);
						});
					},

					//新增
					goAdd: function() {
						var diag = new top.Dialog();
						diag.Drag = true;
						diag.Title = "新增";
						diag.URL = '../../dailywork/apkversion/apkversion_edit.html';
						diag.Width = 1000;
						diag.Height = 800;
						diag.Modal = true; //有无遮罩窗口
						diag.ShowMaxButton = true; //最大化按钮
						diag.ShowMinButton = true; //最小化按钮
						diag.CancelEvent = function() { //关闭事件
							var varSon = diag.innerFrame.contentWindow.document.getElementById('showform');
							if(varSon != null && varSon.style.display == 'none') {
								vm.getList();
							}
							diag.close();
						};
						diag.show();
					},

					//修改
					goEdit: function(id) {
						var diag = new top.Dialog();
						diag.Drag = true;
						diag.Title = "编辑";
						diag.URL = '../../dailywork/apkversion/apkversion_edit.html?FID=' + id;
						diag.Width = 1000;
						diag.Height = 800;
						diag.Modal = true; //有无遮罩窗口
						diag.ShowMaxButton = true; //最大化按钮
						diag.ShowMinButton = true; //最小化按钮
						diag.CancelEvent = function() { //关闭事件
							var varSon = diag.innerFrame.contentWindow.document.getElementById('showform');
							if(varSon != null && varSon.style.display == 'none') {
								vm.getList();
							}
							diag.close();
						};
						diag.show();
					},

					//删除
					goDel: function(id) {
//						swal({
//							title: '',
//							text: "确定要删除吗?",
//							icon: "warning",
//							buttons: true,
//							dangerMode: true,
//						}).then((willDelete) = > {
//							if(willDelete) {
//								this.loading = true;
//								$.ajax({
//									xhrFields: {
//										withCredentials: true
//									},
//									type: "POST",
//									url: httpurl + 'apkversion/delete',
//									data: { APKVERSION_ID: id, tm: new Date().getTime() },
//									dataType: 'json',
//									success: function(data) {
//										if("success" == data.result) {
//											swal("删除成功", "已经从列表中删除!", "success");
//										}
//										vm.getList();
//									}
//								});
//							}
//						})
					},

					//批量操作
					makeAll: function(msg) {
//						swal({
//							title: '',
//							text: msg,
//							icon: "warning",
//							buttons: true,
//							dangerMode: true,
//						}).then((willDelete) = > {
//							if(willDelete) {
//								var str = '';
//								for(var i = 0; i < document.getElementsByName('ids').length; i++) {
//									if(document.getElementsByName('ids')[i].checked) {
//										if(str == '') str += document.getElementsByName('ids')[i].value;
//										else str += ',' + document.getElementsByName('ids')[i].value;
//									}
//								}
//								if(str == '') {
//									$("#cts").tips({
//										side: 2,
//										msg: '点这里全选',
//										bg: '#AE81FF',
//										time: 3
//									});
//									swal("", "您没有选择任何内容!", "warning");
//									return;
//								} else {
//									if(msg == '确定要删除选中的数据吗?') {
//										this.loading = true;
//										$.ajax({
//											xhrFields: {
//												withCredentials: true
//											},
//											type: "POST",
//											url: httpurl + 'apkversion/deleteAll?tm=' + new Date().getTime(),
//											data: { DATA_IDS: str },
//											dataType: 'json',
//											success: function(data) {
//												if("success" == data.result) {
//													swal("删除成功", "已经从列表中删除!", "success");
//												}
//												vm.getList();
//											}
//										});
//									}
//								}
//							}
//						});
					},

					//判断按钮权限，用于是否显示按钮
					hasButton: function() {
						var keys = 'apkversion:add,apkversion:del,apkversion:edit,toExcel';
						$.ajax({
							xhrFields: {
								withCredentials: true
							},
							type: "POST",
							url: httpurl + 'head/hasButton',
							data: { keys: keys, tm: new Date().getTime() },
							dataType: "json",
							success: function(data) {
								if("success" == data.result) {
									vm.add = data.apkversionfhadminadd; //新增权限
									vm.del = data.apkversionfhadmindel; //删除权限
									vm.edit = data.apkversionfhadminedit; //修改权限
									vm.toExcel = data.toExcel; //导出到excel权限
								} else if("exception" == data.result) {
									showException("按钮权限", data.exception); //显示异常
								}
							}
						})
					},

					//导出excel
					goExcel: function() {
//						swal({
//							title: '',
//							text: '确定要导出到excel吗?',
//							icon: "warning",
//							buttons: true,
//							dangerMode: true,
//						}).then((willDelete) = > {
//							if(willDelete) {
//								window.location.href = httpurl + 'apkversion/excel';
//							}
//						});
					},

					//-----分页必用----start
					nextPage: function(page) {
						this.currentPage = page;
						this.getList();
					},
					changeCount: function(value) {
						this.showCount = value;
						this.getList();
					},
					toTZ: function() {
						var toPaggeVlue = document.getElementById("toGoPage").value;
						if(toPaggeVlue == '') {
							document.getElementById("toGoPage").value = 1;
							return;
						}
						if(isNaN(Number(toPaggeVlue))) {
							document.getElementById("toGoPage").value = 1;
							return;
						}
						this.nextPage(toPaggeVlue);
					}
					//-----分页必用----end

				},

				mounted() {
					this.init();
				}
			})
		</script>

	</body>

</html>